<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/views1/DTD/views1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<style>
		.div-dialog-label{ width: 90px; float:left;}
	</style>
	<ui:composition template="/views/layout/main.xhtml">
		<ui:define name="conteudo">
			<h:form id="formPrincipal">
				<div id="divBtn" class="grid_18 div_48">
					<h:panelGroup id="pnlBtn">
						<p:commandButton ajax="true" actionListener="#{perfilBean.preCreatePerfil}" update="formCreate" styleClass="add-notes" title="Novo" oncomplete="dlgCreatePerfil.show();"/>
						<c:if test="#{perfilBean.perfilInstanceTemp.id != null}">
							<p:commandButton ajax="true" actionListener="#{perfilBean.preEditPerfil}" update="formEdit" title="Editar" styleClass="edit-notes" oncomplete="dlgEditPerfil.show();"/>
							<p:commandButton ajax="true" actionListener="#{perfilBean.preDeletePerfil}" update="formDelete" title="Remover" styleClass="delete-notes" oncomplete="dlgDeletePerfil.show();"/>
							<p:commandButton ajax="true" actionListener="#{perfilBean.preDesativarPerfil}" update="formDesativar" styleClass="disable-notes" title="Desativar" oncomplete="dlgDesativarPerfil.show();"/>
							<p:commandButton ajax="true" actionListener="#{perfilBean.preAtivarPerfil}" update="formAtivar"  styleClass="disable-notes" title="Ativar" onclick="dlgAtivarPerfil.show();"/>
						</c:if>
						<p:commandButton widgetVar="btn_Home" styleClass="home" ajax="false" action="#{perfilBean.goHome}" title="Home" />
					</h:panelGroup>
				</div>

				<div class="grid_18 titulo">Perfis</div>

				<div class="grid_18">
					<p:messages id="message"/>
				</div>
				
				<div class="grid_18">
					<p:dataTable widgetVar="dataTablePerfil" 
								id="dataTablePerfil" 
								onRowUnselectUpdate="formPrincipal"
								rowUnselectListener="#{perfilBean.onRowUnselect}"
								onRowSelectUpdate="formPrincipal:pnlBtn, formEdit, formDesativar, formAtivar, formDelete"
								paginator="true"
								lazy="true"
								dynamic="true"
								selection="#{perfilBean.perfilInstanceTemp}" 
								value="#{perfilBean.perfilList}" 
								selectionMode="single"
								var="perfil" update="formPrincipal, formEdit, formDesativar, formAtivar, formDelete"
								emptyMessage="Nenhum registro encontrado!" 
								rows="10">
						<p:column headerText="Nome" sortBy="#{perfil.nome}">
				            <h:outputText value="#{perfil.nome}" />  
				        </p:column>
				        <p:column headerText="Situação" sortBy="#{perfil.situacao}">
				            <h:outputText value="#{perfil.situacao}" />  
				        </p:column> 
					</p:dataTable>
					<br/>	
				</div>
			</h:form>

			<!-- INCLUSAO DE OUTROS XHTMLs -->
			<ui:include src="/views/perfil/_createPerfil.xhtml" />
			<ui:include src="/views/perfil/_deletePerfil.xhtml" />
			<ui:include src="/views/perfil/_editPerfil.xhtml" />
			<ui:include src="/views/perfil/_desativarPerfil.xhtml" />
			<ui:include src="/views/perfil/_ativarPerfil.xhtml" />
		</ui:define>
	</ui:composition>
</f:view>